Skip to content

gh-159430: Add _PyObject_LookupSpecial error checks in bytes/weakref - #159432

Merged
encukou merged 1 commit into
python:mainfrom
msullivan:gh-159430
Oct 15, 2026
Merged

encukou merged 1 commit into
python:mainfrom
msullivan:gh-159430

Conversation

@msullivan

@msullivan msullivan commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

_PyObject_LookupSpecial needs a PyErr_Occurred() check to handle
failures while during the lookup, or else it can fail with a "returned
a result with an exception set" error.

Add some missing ones in bytes and weakref.

AI: a robot reported these bugs to me while I had it trying to collect
a list of something else tangentially related to uses of
_PyObject_LookupSpecial. It also wrote the PR, though none of this
message or the news blurbs.

…akref

_PyObject_LookupSpecial needs a PyErr_Occurred() check to handle
failures while during the lookup, or else it can fail with a "returned
a result with an exception set" error.

Add some missing ones in bytes and weakref/

AI: a robot reported these bugs to me while I had it trying to collect
a list of something else tangentially related to uses of
`_PyObject_LookupSpecial`. It also wrote the PR, though none of this
message or the news blurbs.

@encukou encukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@encukou
encukou merged commit 3646ea5 into python:main Oct 15, 2026
60 checks passed
@encukou encukou added awaiting merge needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Oct 15, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @msullivan for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@miss-islington-app

Copy link
Copy Markdown

Thanks @msullivan for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 15, 2026

Copy link
Copy Markdown

GH-159473 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 15, 2026
@bedevere-app

bedevere-app Bot commented Oct 15, 2026

Copy link
Copy Markdown

GH-159474 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 15, 2026
@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Windows Server 2025 Refleaks 3.x (tier-1) has failed when building commit 3646ea5.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/2263/builds/349) and take a look at the build logs.
  4. Check if the failure is related to this commit (3646ea5) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/2263/builds/349

Test leaking resources:

  • test_sslproto: memory blocks
  • test_sslproto: references

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\support\os_helper.py", line 541, in temp_dir
    os.mkdir(path)
    ~~~~~~~~^^^^^^
FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'B:\\uildarea\\3.x.ware-ws2025.refleak\\build\\build\\test_python_4932æ'
Stack (most recent call last):
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\runpy.py", line 201, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\libregrtest\worker.py", line 141, in <module>
    main()
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\libregrtest\worker.py", line 136, in main
    with os_helper.temp_cwd(work_dir, quiet=True):
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\contextlib.py", line 203, in __enter__
    for once in self.gen:
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\support\os_helper.py", line 614, in temp_cwd
    with temp_dir(path=name, quiet=quiet) as temp_path:


Traceback (most recent call last):
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\support\os_helper.py", line 541, in temp_dir
    os.mkdir(path)
    ~~~~~~~~^^^^^^
FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'B:\\uildarea\\3.x.ware-ws2025.refleak\\build\\build\\test_python_5312æ'
Stack (most recent call last):
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\runpy.py", line 201, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\libregrtest\worker.py", line 141, in <module>
    main()
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\libregrtest\worker.py", line 136, in main
    with os_helper.temp_cwd(work_dir, quiet=True):
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\contextlib.py", line 203, in __enter__
    for once in self.gen:
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\support\os_helper.py", line 614, in temp_cwd
    with temp_dir(path=name, quiet=quiet) as temp_path:


Traceback (most recent call last):
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\threading.py", line 1218, in _bootstrap_inner
    self._context.run(self.run)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\functional.py", line 227, in run
    self._run()
    ~~~~~~~~~^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\functional.py", line 261, in _run
    self._test._abort_socket_test(ex)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\functional.py", line 110, in _abort_socket_test
    self.fail(ex)
    ~~~~~~~~~^^^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\unittest\case.py", line 772, in fail
    raise self.failureException(msg)
AssertionError: [WinError 10053] An established connection was aborted by the software in your host machine
k


Traceback (most recent call last):
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\functional.py", line 255, in _run
    self._handle_client(conn)
    ~~~~~~~~~~~~~~~~~~~^^^^^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\functional.py", line 264, in _handle_client
    self._prog(TestSocketWrapper(sock))
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\test_sslproto.py", line 964, in server
    sock.unwrap()
    ~~~~~~~~~~~^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\ssl.py", line 1412, in unwrap
    s = self._sslobj.shutdown()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host


Traceback (most recent call last):
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\functional.py", line 255, in _run
    self._handle_client(conn)
    ~~~~~~~~~~~~~~~~~~~^^^^^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\functional.py", line 264, in _handle_client
    self._prog(TestSocketWrapper(sock))
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\test_sslproto.py", line 964, in server
    sock.unwrap()
    ~~~~~~~~~~~^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\ssl.py", line 1412, in unwrap
    s = self._sslobj.shutdown()
ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine


Traceback (most recent call last):
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\threading.py", line 1218, in _bootstrap_inner
    self._context.run(self.run)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\functional.py", line 227, in run
    self._run()
    ~~~~~~~~~^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\functional.py", line 261, in _run
    self._test._abort_socket_test(ex)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\test\test_asyncio\functional.py", line 110, in _abort_socket_test
    self.fail(ex)
    ~~~~~~~~~^^^^
  File "B:\uildarea\3.x.ware-ws2025.refleak\build\Lib\unittest\case.py", line 772, in fail
    raise self.failureException(msg)
AssertionError: [WinError 10054] An existing connection was forcibly closed by the remote host
k

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants